<?php
header("Access-Control-Allow-Origin:*");
/*
参数:
cid //课时名称
uid //学生编号
*/
require_once '../../dz_framework/init.php';

$hid = isset($_GET['hid'])?$_GET['hid']:'';
$tid = isset($_GET['tid'])?$_GET['tid']:'';

$tid_info = DB::fetch_first("select item_content,type from ".DB::table('study_item')." where tid='".$tid."'");	
$choice_info = unserialize($tid_info['item_content']);
foreach ( $choice_info as $key=>$value)
{
	$choice_array[$key] = 0;
}
if( $tid_info['type']==3 )
{
	$choice_array[0] = 0;
	$choice_array[1] = 0;
}
$news_choice_count = $choice_array;

$all_student_exam_info = DB::fetch_all("select * from ".DB::table('student_practice')." where h_id='".$hid."'");	

foreach ( $choice_array as $key=>$value)
{
	foreach ( $all_student_exam_info as $k=>$v)
	{
		$sdaan = '';
		$sdaan = unserialize($v['daan']);
		//echo $sdaan[$tid]['choice'].'-'.$key.'|';
		if( $sdaan[$tid]['choice'] != '-1' )    
		{
	        if ( strexists ( (string)$sdaan[$tid]['choice'] , (string)$key) ) {        	
				   $news_choice_count[$key] = $news_choice_count[$key]+1;
				}
		}                            
	}	
}
$count_num['data'] = $news_choice_count;
echo json_encode($count_num);
//print_r($news_choice_count);
//{
//data:[33,22,7,34]
//}